package com.chhlz.module.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chhlz.module.base.dao.BillDao;
import com.chhlz.module.base.model.Bill;
import com.chhlz.module.service.BillService;

@Service
public class BillServiceImpl implements BillService{
	@Autowired
	private BillDao BillDao;

	@Override
	public int getTotal() {
		return this.BillDao.countAll();
	}

	@Override
	public boolean isExist(String billNumber) {
		boolean flag = false;
		String hql="from Bill b where b.billNumber=" + billNumber;
		if (BillDao.find(hql).size()>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public int save(Bill t) {
		return this.BillDao.save(t);
	}

	@Override
	public void update(Bill t) {
		this.BillDao.update(t);
	}

	@Override
	public void delete(int id) {
		Bill b = this.BillDao.get(id);
		this.BillDao.delete(b);
	}

	@Override
	public List<Bill> findAll(int page, int rows, String sort, String order) {
		return this.BillDao.findAll(page, rows, sort, order);
	}

}
